using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnFixedSpeedControl : MonoBehaviour
{
    public float speed = 0.5f;
    public GameObject[] cloudPrefabs;

    void Update()
    {
        foreach(Transform tran in transform){
            Vector2 pos = tran.position;
            pos.x -= speed * Time.deltaTime;
            if(pos.x < -35.9f){
                Transform newTrans = Instantiate(cloudPrefabs[Random.Range(0,cloudPrefabs.Length)],transform).transform;
                Vector2 newPos = newTrans.position;
                newPos.x = pos.x+35.9f*2;
                newTrans.position = newPos;
                Destroy(tran.gameObject);
            }
            tran.position = pos;
        }
    }
}
